JavaScript Fundamental Objects

Visualizing the core building blocks of JavaScript.

Object

The most fundamental data type. It is a collection of key-value pairs, where keys are strings or Symbols, and values can be of any data type. It's the base of almost everything in JavaScript.

let user = {
  name: 'Alice',
  age: 30
};

An object is like a labeled container with different slots for its properties.

name: 'Alice'
age: 30

Function

A callable object that executes a block of code. Functions can be assigned to variables, passed as arguments, and returned from other functions, making them "first-class citizens."

const greet = (name) => {
  return `Hello, ${name}!`;
};

Think of a function as a machine that takes an input, processes it, and produces an output.

Input
Function (process)
Output

Boolean

A primitive data type that represents one of two values: `true` or `false`. It's essential for logical operations and control flow in programming.

let isLightOn = true;
if (isLightOn) { ... }

A boolean is like a light switch, it can only be in one of two states: `on` (true) or `off` (false).


Symbol

A unique and immutable primitive value. It's often used to create unique object property keys to avoid naming conflicts, especially in large libraries.

const id = Symbol('id');
let obj = {
  [id]: 123
};

A Symbol acts as a secret, unique identifier for an object property, preventing accidental clashes with other keys.

Card: User Profile

Public ID: 456

Public Name: Jane Doe

Card: Library Data

Secret Key: [Symbol(id)]

Value: 123